home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
embedded
/
mcu
/
hc05iic.arc
/
IIC.LST
< prev
next >
Wrap
File List
|
1990-06-15
|
9KB
|
170 lines
M6805 Portable Cross Assembler 0.05 MS-DOS/PC-DOS Page 1
Fri Jun 15 18:40:20 1990
Command line:
C:\DOS\PASM05.EXE -l iic.lst iic.s
Options list:
ON - b - Printing of macro definitions
ON - c - Printing of macro calls
OFF - d - Placing of symbolic debugging information in COFF
OFF - e - Printing of macro expansions
ON - f - Printing of conditional directives
OFF - g - Printing of generated constants list
OFF - q - Expanding and printing of structured syntax
OFF - s - Printing of symbol table
OFF - u - Printing of conditional unassembled source
OFF - x - Printing of cross reference table
OFF - m - Suppress printing of error messages
ON - w - Printing of warning messages
OFF - v - Suppress printing of updated status
OFF - y - Enabling of sgs extensions
ON - o - Create object code
ON - - Formatting of source line listing
Create listing file - l - iic.lst
Xdefs:
NONE
Xrefs:
NONE
Input file(s): iic.s (106 lines) c4c8reg.s (260 lines)
Output file: iic.o
Listing file: iic.lst
M6805 Portable Cross Assembler 0.05 iic.s Page 2
Fri Jun 15 18:40:20 1990
Options - MD,MC,NOG,NOU,W,NOMEX,CL,FMT,O
LINE S PC OPCO OPERANDS S LABEL MNEMO OPERANDS COMMENT
00001 opt mul,cmos,lle=132
00002 * Software for 68hc05 to control IIC peripherals using the SPI interface
00003 * adapted from Naji Naufel's article in EDN, Feb 18 1988
00004 * Port C Bits 0 and 1 are used to generate the start and stop bits required
00005
00006 opt nol
00007 include c4c8reg.s
00008 opt l
00009
00010 asct
00011 A 0000 0000 A data equ PC0 IIC data line controlled by PC0
00012 A 0000 0001 A .data equ .PC0
00013 A 0000 0001 A clk equ PC1 IIC clock line controlled by PC1
00014 A 0000 0002 A .clk equ .PC1
00015 A 0000 0002 A iicport equ PORTC
00016 A 0000 0006 A iicddr equ DDRC
00017
00018 A 0000 0000 A waddr equ 0 IIC write address
00019 A 0000 0001 A raddr equ 1 IIC read address
00020
00021 * init initializes the I/O port hardware
00022
00023 A 0050 org $50 RAM location - ACK flag
00024 A 0050 01 A ack rmb 1 set bit 0 to value of ACK bit desired after byte
00025 A 0051 01 A control rmb 1 RAM location to store control word to IIC device
00026 A 0052 04 A ram rmb 4 ram buffer for read command
00027
00028 A 0100 org $100 start of ROM
00029 A 0100 a6 03 A init lda #.data+.clk set clock and data high
00030 A 0102 b7 02 A sta iicport
00031 A 0104 b7 06 A sta iicddr both bits output
00032 A 0106 3f 0a A clr SPCR make sure SPI is didsabled to start
00033 A 0108 81 rts done
00034
00035 * w_start transfers a byte from the HC05 SPI to the IIC peripheral
00036 * Including a start bit. nostart sends the byte with no start bit
00037 * On entry the data is in the accumulator
00038
00039 A 0109 11 02 A w_start bclr data,iicport set data line low - start bit
00040 A 010b 13 02 A bclr clk,iicport drive clock low
00041 A 010d ae 50 A nostart ldx #.SPE+.MSTR enable spi
00042 A 010f bf 0a A stx SPCR
00043 A 0111 10 02 A bset data,iicport let data line go high
00044 A 0113 b7 0c A sta SPDR send the data
00045 A 0115 0f 0bfd 0115 wait brclr SPIF,SPSR,wait poll while data shifted out
00046 * set SPIE bit for interrupt-driven transfer
00047 A 0118 b6 0a A lda SPCR disable SPI
00048 A 011a a4 bf A and #.SPE!X$ff
00049 A 011c b7 0a A sta SPCR
00050 A 011e 00 5007 0128 brset 0,ack,hiack test value of ack bit desired
00051 A 0121 11 02 A bclr data,iicport ack must be low - clear data line
00052 A 0123 ad 03 0128 bsr hiack generate clock pulse
M6805 Portable Cross Assembler 0.05 iic.s Page 3
Fri Jun 15 18:40:20 1990
Options - MD,MC,NOG,NOU,W,NOMEX,CL,FMT,O
LINE S PC OPCO OPERANDS S LABEL MNEMO OPERANDS COMMENT
00053 A 0125 10 02 A bset data,iicport let data go high again
00054 A 0127 81 rts
00055
00056 A 0128 12 02 A hiack bset clk,iicport pulse clock high, then low
00057 A 012a 21 fc 0128 brn hiack delay - 3 'E' clocks
00058 A 012c 13 02 A bclr clk,iicport
00059 A 012e 81 rts
00060
00061 * This subroutine creates a stop condition
00062
00063 A 012f 11 02 A stop bclr data,iicport strobe data low
00064 A 0131 12 02 A bset clk,iicport positive edge on clock line
00065 A 0133 10 02 A bset data,iicport put data back to idle state
00066 A 0135 81 rts
00067
00068 * This subroutine sends an address byte, followed by a control byte in CONTROL
00069
00070 A 0136 a6 00 A addrcnt lda #waddr load address value
00071 A 0138 ad cf 0109 bsr w_start send with start bit
00072 A 013a b6 51 A lda control get desired control value
00073 A 013c ad cf 010d bsr nostart send without start bit
00074 A 013e 81 rts done
00075
00076 * This subroutine reads four bytes from the peripheral
00077
00078 A 013f 3f 51 A read clr control control = 0
00079 A 0141 10 50 A bset 0,ack ack bit should be 1
00080 A 0143 ad f1 0136 bsr addrcnt send address followed by control
00081 A 0145 ad e8 012f bsr stop send stop bit
00082 A 0147 a6 01 A lda #raddr now send read address
00083 A 0149 ad be 0109 bsr w_start
00084 A 014b 11 50 A bclr 0,ack ack bit is 1
00085 A 014d a6 ff A lda #$ff read 4 bytes - must send ones during process
00086 A 014f ad bc 010d bsr nostart
00087 A 0151 b6 0c A lda SPDR get received data
00088 A 0153 b7 54 A sta ram+2 save in RAM
00089 A 0155 a6 ff A lda #$ff read 4 bytes - must send ones during process
00090 A 0157 ad b4 010d bsr nostart
00091 A 0159 b6 0c A lda SPDR get received data
00092 A 015b b7 55 A sta ram+3 save in RAM
00093 A 015d a6 ff A lda #$ff read 4 bytes - must send ones during process
00094 A 015f ad ac 010d bsr nostart
00095 A 0161 b6 0c A lda SPDR get received data
00096 A 0163 b7 53 A sta ram+1 save in RAM
00097 A 0165 10 50 A bset 0,ack last byte has ack bit set to 1
00098 A 0167 a6 ff A lda #$ff read 4 bytes - must send ones during process
00099 A 0169 ad a2 010d bsr nostart
00100 A 016b ad c2 012f bsr stop send stop bit
00101 A 016d b6 0c A lda SPDR get received data
00102 A 016f b7 52 A sta ram save in RAM
00103 A 0171 81 rts done
00104
M6805 Portable Cross Assembler 0.05 iic.s Page 4
Fri Jun 15 18:40:20 1990
Options - MD,MC,NOG,NOU,W,NOMEX,CL,FMT,O
LINE S PC OPCO OPERANDS S LABEL MNEMO OPERANDS COMMENT
00105 end
00106
Total number of errors: 0
Total number of warnings: 0
Total number of lines: 366
Number of bytes in section ASCT: 120
Number of bytes in program: 120